package com.shadowtorcher.stdisk.util;


import java.util.HashMap;
import java.util.Map;

public class FileTypePatternGenerator {
    public static Map<String, String> data = new HashMap() {{
        put("3ds", "graphics");
        put("3g2", "video");
        put("3gp", "video");
        put("7z", "archive");
        put("aac", "audio");
        put("adw", "document");
        put("ai", "image");
        put("aifc", "audio");
        put("aiff", "audio");
        put("alc", "misc");
        put("ari", "archive");
        put("art", "image");
        put("asc", "text");
        put("asf", "video");
        put("asm", "text");
        put("asx", "video");
        put("au", "audio");
        put("avi", "video");
        put("aw", "document");
        put("b", "misc");
        put("bat", "software");
        put("bib", "text");
        put("bibtex", "text");
        put("bin", "archive");
        put("bmp", "image");
        put("bsd", "misc");
        put("bz", "archive");
        put("bz2", "archive");
        put("c", "text");
        put("c3d", "misc");
        put("cab", "archive");
        put("cache", "misc");
        put("cap", "misc");
        put("cc", "text");
        put("cdf", "misc");
        put("cdr", "graphics");
        put("cdx", "graphics");
        put("cef", "misc");
        put("cer", "misc");
        put("cert", "misc");
        put("chm", "misc");
        put("cif", "misc");
        put("class", "software");
        put("cls", "text");
        put("cmb", "audio");
        put("cml", "misc");
        put("com", "software");
        put("cpa", "misc");
        put("cpio", "archive");
        put("cpp", "text");
        put("cpt", "software");
        put("crl", "misc");
        put("crt", "misc");
        put("cs", "text");
        put("csg", "misc");
        put("csh", "software");
        put("csm", "misc");
        put("csml", "misc");
        put("csv", "text");
        put("ctx", "misc");
        put("cub", "misc");
        put("d64", "software");
        put("dat", "misc");
        put("db", "misc");
        put("dbf", "misc");
        put("dcr", "document");
        put("deb", "software");
        put("dib", "image");
        put("dif", "video");
        put("diff", "text");
        put("dir", "document");
        put("divx", "video");
        put("djvu", "document");
        put("dll", "software");
        put("dmg", "software");
        put("dmp", "misc");
        put("dms", "software");
        put("doc", "document");
        put("docm", "document");
        put("document", "document");
        put("docx", "document");
        put("dot", "document");
        put("dpg", "graphics");
        put("drc", "video");
        put("drv", "software");
        put("dtd", "text");
        put("dv", "video");
        put("dvi", "document");
        put("dwf", "graphics");
        put("dwg", "graphics");
        put("dx", "misc");
        put("dxf", "image");
        put("dxr", "document");
        put("emb", "misc");
        put("embl", "misc");
        put("ent", "misc");
        put("eps", "image");
        put("epub", "document");
        put("erl", "text");
        put("etx", "text");
        put("exe", "software");
        put("ez", "document");
        put("f", "text");
        put("f90", "text");
        put("fchk", "misc");
        put("feed", "misc");
        put("fig", "image");
        put("fits", "image");
        put("flac", "audio");
        put("flv", "video");
        put("for", "text");
        put("fp3", "document");
        put("fts", "image");
        put("gam", "misc");
        put("gau", "misc");
        put("gen", "misc");
        put("gif", "misc");
        put("gp3", "misc");
        put("gp4", "misc");
        put("gp5", "misc");
        put("gpg", "text");
        put("gpx", "misc");
        put("gsm", "audio");
        put("gtar", "archive");
        put("gz", "archive");
        put("h", "text");
        put("hdf", "archive");
        put("hdr", "misc");
        put("hin", "misc");
        put("hlp", "document");
        put("hqx", "software");
        put("hs", "text");
        put("hvs", "audio");
        put("hwp", "document");
        put("ical", "text");
        put("ico", "image");
        put("ics", "document");
        put("ief", "image");
        put("igs", "image");
        put("inp", "misc");
        put("iso", "archive");
        put("ist", "misc");
        put("istr", "misc");
        put("jar", "software");
        put("java", "text");
        put("jdx", "misc");
        put("jnlp", "software");
        put("jpe", "image");
        put("jpeg", "image");
        put("jpg", "image");
        put("js", "text");
        put("json", "text");
        put("kar", "audio");
        put("kin", "misc");
        put("kml", "misc");
        put("kmz", "misc");
        put("latex", "text");
        put("lha", "archive");
        put("lhs", "text");
        put("lit", "document");
        put("log", "text");
        put("lwp", "document");
        put("lzh", "archive");
        put("lzx", "archive");
        put("m", "text");
        put("m1v", "video");
        put("m2v", "video");
        put("m3u", "audio");
        put("m4a", "video");
        put("m4p", "audio");
        put("m4r", "audio");
        put("m4v", "video");
        put("ma", "text");
        put("mac", "software");
        put("man", "text");
        put("marc", "misc");
        put("mb", "text");
        put("mcd", "graphics");
        put("mcm", "misc");
        put("md5", "misc");
        put("md5sum", "misc");
        put("mdb", "document");
        put("mdz", "audio");
        put("mesh", "graphics");
        put("mht", "text");
        put("midi", "audio");
        put("mif", "document");
        put("mkv", "video");
        put("mmd", "misc");
        put("mmf", "audio");
        put("mno", "software");
        put("mod", "audio");
        put("model", "misc");
        put("mol", "misc");
        put("mol2", "misc");
        put("mov", "video");
        put("movie", "video");
        put("mp2", "video");
        put("mp3", "audio");
        put("mp4", "video");
        put("mpa", "video");
        put("mpc", "misc");
        put("mpd", "graphics");
        put("mpe", "video");
        put("mpg", "video");
        put("mrc", "document");
        put("msi", "software");
        put("mus", "audio");
        put("mws", "text");
        put("nb", "text");
        put("nc", "misc");
        put("nth", "misc");
        put("nwc", "audio");
        put("oda", "text");
        put("odb", "misc");
        put("odc", "image");
        put("odf", "misc");
        put("odg", "image");
        put("odm", "document");
        put("odp", "document");
        put("ods", "document");
        put("odt", "document");
        put("oga", "audio");
        put("ogg", "video");
        put("ogm", "video");
        put("ogv", "video");
        put("oprg", "software");
        put("otf", "document");
        put("otg", "image");
        put("oth", "document");
        put("otp", "document");
        put("ots", "document");
        put("ott", "document");
        put("oxt", "misc");
        put("p", "text");
        put("pano", "image");
        put("pas", "text");
        put("pbm", "image");
        put("pct", "graphics");
        put("pcx", "image");
        put("pdb", "misc");
        put("pdf", "document");
        put("pfr", "misc");
        put("pgm", "image");
        put("pgn", "misc");
        put("pgp", "text");
        put("pict", "graphics");
        put("pk3", "misc");
        put("pl", "text");
        put("plot", "misc");
        put("pls", "misc");
        put("pm", "text");
        put("png", "image");
        put("pnm", "image");
        put("po", "text");
        put("pov", "graphics");
        put("ppm", "image");
        put("pps", "document");
        put("ppsx", "document");
        put("ppt", "document");
        put("pptm", "document");
        put("pptx", "document");
        put("ps", "document");
        put("psd", "image");
        put("ptb", "audio");
        put("pub", "document");
        put("py", "text");
        put("pymolrpc", "misc");
        put("qcp", "audio");
        put("qt", "video");
        put("qti", "image");
        put("qtif", "image");
        put("qtl", "audio");
        put("qtz", "software");
        put("qxd", "document");
        put("ra", "audio");
        put("ram", "video");
        put("rar", "archive");
        put("ras", "image");
        put("rb", "text");
        put("rbs", "audio");
        put("rd", "misc");
        put("rdf", "text");
        put("reg", "text");
        put("rep", "document");
        put("rgb", "image");
        put("rm", "video");
        put("rmi", "audio");
        put("rmvb", "audio");
        put("roff", "text");
        put("rpm", "software");
        put("rtf", "document");
        put("rtx", "document");
        put("rv", "video");
        put("sdf", "misc");
        put("sdw", "document");
        put("sgd", "misc");
        put("sgm", "text");
        put("sgml", "text");
        put("sh", "software");
        put("shar", "archive");
        put("sid", "audio");
        put("sig", "text");
        put("sign", "text");
        put("sit", "archive");
        put("skc", "misc");
        put("smil", "text");
        put("snd", "audio");
        put("sndh", "audio");
        put("spc", "misc");
        put("spx", "audio");
        put("sql", "text");
        put("sqlite", "text");
        put("std", "image");
        put("sti", "document");
        put("stk", "document");
        put("stl", "graphics");
        put("stw", "document");
        put("sty", "text");
        put("svg", "graphics");
        put("svgz", "graphics");
        put("swf", "software");
        put("sxc", "document");
        put("sxd", "image");
        put("sxi", "document");
        put("sxw", "document");
        put("sxy", "document");
        put("t", "text");
        put("tar", "archive");
        put("tcl", "text");
        put("tex", "text");
        put("texi", "text");
        put("texinfo", "text");
        put("tga", "image");
        put("tgz", "archive");
        put("thm", "misc");
        put("thmx", "document");
        put("tiff", "image");
        put("torrent", "archive");
        put("tpl", "document");
        put("tr", "text");
        put("ts", "video");
        put("tsv", "text");
        put("ttf", "misc");
        put("txt", "text");
        put("vbs", "text");
        put("vcf", "text");
        put("vcs", "text");
        put("vim", "text");
        put("vob", "video");
        put("voc", "audio");
        put("vqd", "audio");
        put("vrml", "graphics");
        put("vsd", "graphics");
        put("vxml", "misc");
        put("wav", "audio");
        put("wax", "audio");
        put("wir", "misc");
        put("wma", "audio");
        put("wmf", "graphics");
        put("wml", "text");
        put("wmv", "video");
        put("wmx", "video");
        put("wmz", "graphics");
        put("wpd", "document");
        put("wpl", "misc");
        put("wps", "document");
        put("wri", "document");
        put("wrl", "graphics");
        put("wsdl", "text");
        put("wvx", "video");
        put("x3d", "graphics");
        put("x3db", "graphics");
        put("x3dv", "graphics");
        put("xbm", "image");
        put("xcf", "image");
        put("xls", "document");
        put("xlsm", "document");
        put("xlsx", "document");
        put("xlt", "document");
        put("xm", "audio");
        put("xml", "text");
        put("xpi", "software");
        put("xpm", "image");
        put("xsd", "text");
        put("xspf", "audio");
        put("xul", "text");
        put("xwd", "image");
        put("xwrl", "graphics");
        put("xyz", "misc");
        put("z", "misc");
        put("zip", "archive");
        put("air", "mobile");
        put("apk", "mobile");
        put("aos", "mobile");
        put("cod", "mobile");
        put("prc", "mobile");
        put("sis", "mobile");
    }};

    public static String getFilesuffix(String filename) {
        String[] name = filename.split("\\.");
        if (name.length == 0)
            return null;
        else
            return name[name.length - 1];
    }

    public static String getType(String filename) {
        String type = data.get(getFilesuffix(filename));
        if (type == null)
            return "other";
        else
            return type;
    }

    public static String getRegular(String str) {
        return ".*" + str + ".*";
    }
}
